<%@ page import="edu.session.User" %>
<%@ page import="java.util.Collections" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 16690
  Date: 2020/9/16
  Time: 21:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="label" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    User user = new User();
    user.setUsername("张三");
    user.setPassword("123123");
    pageContext.setAttribute("user01", user);

    User user2 = new User();
    user2.setUsername("李四");
    user2.setPassword("234234");
    request.setAttribute("user01", user2);

    User user3 = new User();
    user3.setUsername("王五");
    user3.setPassword("234234");
    session.setAttribute("user01", user3);

    User user4 = new User();
    user4.setUsername("古一");
    user4.setPassword("234234");
    application.setAttribute("user01", user4);

    List<User> list = new ArrayList<>();
    Collections.addAll(list,user,user2,user3,user4);
    request.setAttribute("list",list);
%>
<label:set var="str" value="<%=1+1%>" scope="session" target="user" property="name"/>
${sessionScope.get("str")}
<hr>
${pageContext.getAttribute("str")}
<hr>
${pageScope.get("str")}
<hr>
${requestScope.get("str")}
<hr>
${applicationScope.get("str")}
<hr>

<%--
<%
    user = new User();
    request.setAttribute("user",user);
%>
<label:set target="${user}" property="password" value="123"/>

${user.password}--%>
<hr>
remove标签
<label:remove var="str" scope="session"/>
${sessionScope.get("str")}
<hr>

if标签
<label:if test="${1==1}" scope="session" var="t1">
    <h1>只有if为true才能看见</h1>
</label:if>
${sessionScope.get("t1")}
<hr>

foreach标签
<label:forEach var="i" items="${list}" begin="0" end="${list.size()}" step="1" varStatus="vs">
    ${i.username}
    ${vs.begin}: ${vs.step}:${vs.first}
</label:forEach>
</body>
</html>
